#ifndef EEPROM_H
#define EEPROM_H

#include <stdint.h>
#include <intrins.h>
#include "STC8H.H"
#include "string.h"

void EEPROM_Init(void);
void EEPROM_Idle(void);

uint8_t EEPROM_ReadByte(uint16_t addr);
void EEPROM_WriteByte(uint16_t addr, uint8_t _dat);
void EEPROM_EraseSector(uint16_t addr);

// 新增安全写入的接口函数
void EEPROM_SafeWriteByte(uint16_t addr, uint8_t _dat);
void EEPROM_SafeWriteUint16(uint16_t addr, uint16_t _dat);

void EEPROM_WriteInt16(uint16_t addr, int16_t _dat);
int16_t EEPROM_ReadInt16(uint16_t addr);
uint16_t EEPROM_ReadUint16(uint16_t addr);
void EEPROM_WriteFloat(uint16_t addr, float _dat);
float EEPROM_ReadFloat(uint16_t addr);

#endif // EEPROM_H